<?php

class Application_Form_SelectLeague extends Zend_Form
{

    public function init()
    {   
        $this->setMethod('post')
             ->setAction('/select-league/select-league');
        
        $selectLeague = new Zend_Dojo_Form_Element_FilteringSelect(
                'leagueId',
                array(
                    'label'         => 'Liga wählen',
                )
        );
        
        $selectLeagueButton = new Zend_Dojo_Form_Element_SubmitButton(
                'selectLeagueButton',
                array(
                    'label'         => 'Fertig',
                )
        );
        
        $this->addElements(
                array(
                    $selectLeague,
                    $selectLeagueButton,
                )
        );
        
        // Element mit Daten aus DB füllen
        $this->_getLeagues();
        
    }
    
    protected function _getLeagues()
    {
        $getLeagueElement = $this->getElement('leagueId');
        $leagueModel = new Application_Model_DbTable_Ligen();
        $result = $leagueModel->fetchAll();
        
        foreach($result as $row) {
            $getLeagueElement->addMultiOptions(array($row->ligaId => $row->ligaName));
        }
        
        
    }


}